home *** CD-ROM | disk | FTP | other *** search
- #include <stdlib.h>
- #include <stdio.h>
- #include <dos.h>
- #include "define.h"
- /* #include <cdrfrb.h> */
-
- #ifdef DEBUG
- main(int argc, char *argv[])
- {
- struct TIMEADRS time;
- char buf[2340];
- int i;
-
- if (argc > 1) {
- printf("input is %s\n", argv[1]);
- time.min = (u_char) atoi(argv[1]);
- time.sec = 0;
- time.frame = 0;
- printf("Read %d分\n", time.min);
- printf("return is %x\n", cdr_tread(0, &time, buf, 1));
- for (i=0; i<2048; i++) {
- printf("%2x", buf[i]);
- if ((i & 0x1f) == 0x1f) {
- puts("");
- }
- }
- }
- }
- #endif
-
- /* データの読み取り(時間指定) */
- /*
- * device_no: device number (Towns CD-ROM -> 0)
- * time: 時間
- * buffer: 転送アドレス
- * count: 読み込みセクタ数
- * return: 0 -> 正常終了, 0以外 -> エラー
- */
-
- int cdr_tread(int device_no, struct TIMEADRS *time, char *buffer, u_int count)
- {
- union REGS reg;
- struct SREGS seg;
-
- if (time == NULL || buffer == NULL) {
- return -1;
- }
-
- segread(&seg);
- reg.h.ah = 0x15;
- reg.h.al = (0xC0 | (u_char) device_no);
- reg.x.cx = 0x0000;
- reg.h.cl = (u_char) time->min; /* 分 */
- reg.h.dh = (u_char) time->sec; /* 秒 */
- reg.h.dl = (u_char) time->frame; /* フレーム */
- reg.x.bx = count;
- reg.x.di = (u_int) buffer;
-
- int86x(0x93, ®, ®, &seg);
-
- if (reg.h.ah == 0) {
- return 0;
- } else if (reg.h.ah == 0x02) { /* device number error */
- return DEVERR;
- } else if (reg.h.ah == 0x10) { /* cd-da plaing */
- return DEVPLY;
- } else { /* (reg.h.ah == 0x80) hard ware error */
- return reg.x.cx;
- }
- }
- #define cdr_tread2(device_no, time, buffer, count) cdr_tread(device_no, time, buffer, count)
-